﻿using System.IO;
using Luban;
using UnityEngine;

public class LubanDatatableLoader : MonoBehaviour
{

    public static cfg.Tables tables;

    // Start is called before the first frame update
    // 游戏启动时加载配置表数据
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
    public static void init()
    {
        tables = new cfg.Tables(LoadByteBuf);
        // var refv = tables.TbItem.DataList[0];
        // Debug.LogFormat("refv:{0}", refv);
        UnityEngine.Debug.Log("== load succ==");
    }

    private static ByteBuf LoadByteBuf(string file)
    {
        return new ByteBuf(File.ReadAllBytes($"{Application.dataPath}/../../paradogs2-datatables-output/{file}.bytes"));
    }
}
